package org.example.controller;

import org.example.commons.ApiResponse;
import org.example.dto.ItemRequest;
import org.example.dto.ItemResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
public class ItemController {
    @GetMapping("/a")
    public String a() {
        return "a";
    }


    @PostMapping("getItem")
    public ApiResponse<ItemResponse> getItem(@Valid @RequestBody ItemRequest request) throws Exception {
        if (System.currentTimeMillis()%2 == 0) {
            Thread.sleep(100);
        }
        return ApiResponse.success(new ItemResponse(request.getId(), null));
    }
}
